package com.xx.cloud.pay.controller;

import cn.hutool.core.lang.Validator;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.xx.cloud.pay.result.R;
import com.xx.cloud.pay.service.ExportService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import java.util.List;

@RestController
@RequestMapping("/pay")
@CrossOrigin("*")
public class ExportController {

    @Autowired
    private ExportService exportService;

    /**
     * 导入
     *
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("import")
    public R export(@RequestParam("file") MultipartFile file) throws IOException {
        return exportService.export(file);
    }

    /**
     * 动态字段导出
     *
     * @param list
     * @param response
     * @throws Exception
     */
    @PostMapping("/export")
    public void getName(@RequestBody List<String> list, HttpServletResponse response) {
        exportService.getStudent(list, response);
    }

}
